﻿Imports DAO
Imports DTO
Public Class HangHoaBUS

    Public Shared Function LoadBangHoangHoa() As DataTable
        Return HangHoaDAO.LoadBangHangHoa()
    End Function

    Public Shared Function LoadclMaHang_tabMuaHang() As DataTable
        Return HangHoaDAO.LoadclMaHang_tabMuaHang
    End Function

    Public Shared Function LayDSLoaiHHCbx() As DataTable
        Return HangHoaDAO.LayDSLoaiHHCbx()
    End Function

    Public Shared Function LayDSHangHoa() As DataTable
        Return HangHoaDAO.LayDSHangHoa()
    End Function

    Public Shared Function ThemHangHoa(hh As HangHoaDTO) As Boolean
        Dim kt As Boolean = True
        If hh.TenHangHoa.Length = 0 Or hh.DiaChiAnh.Length = 0 Then
            Return False
        End If
        HangHoaDAO.ThemHangHoa(hh)
        Return kt
    End Function

    Public Shared Function CapNhatHangHoa(hh As HangHoaDTO) As Boolean
        Dim kt As Boolean = True
        If hh.TenHangHoa.Length = 0 Then
            Return False
        End If
        HangHoaDAO.CapNhatHangHoa(hh)
        Return kt
    End Function

    Public Shared Function XoaHangHoa(hh As HangHoaDTO) As Boolean
        Dim kt As Boolean = True
        HangHoaDAO.XoaHangHoa(hh)
        Return kt
    End Function

    Public Shared Sub LayMaHangHoaCbx(ByVal mahh As String, ByRef ncc As String, ByRef nh As String, ByRef lhh As Integer, ByRef dv As String, ByRef kmd As String)
        HangHoaDAO.LayMaHangHoaCbx(mahh, ncc, nh, lhh, dv, kmd)
    End Sub

    Shared Function layDSHangHoaBanHang() As List(Of HangHoaBanHangDTO)
        Dim ds As List(Of HangHoaBanHangDTO) = HangHoaDAO.layDSHangHoaBanHang()
        Dim stt As Integer = 0
        For Each hh As HangHoaBanHangDTO In ds
            hh.STT = stt
            stt += 1
        Next
        Return ds
    End Function

End Class
